package blog.controller.login;

import blog.service.LoginService;
import blog.vo.ErrorCode;
import blog.vo.LoginUserVo;
import blog.vo.Result;
import blog.vo.params.LoginParam;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    // 登录
    @PostMapping
    public Result login(@RequestBody LoginParam loginParam) throws JsonProcessingException {

        Result token = loginService.login(loginParam.getAccount(), loginParam.getPassword());

        return token;
    }

}
